<?php

namespace App\Console;

use App\Console\Commands\CalcAccountDayProp;
use App\Console\Commands\CalcAccountDayStat;
use App\Console\Commands\CalcAccountExtraData;
use App\Console\Commands\CalcActivityTypeInfo;
use App\Console\Commands\CalcActivityTypeStat;
use App\Console\Commands\CalcCplIssueConfigStat;
use App\Console\Commands\CalcCplIssueStat;
use App\Console\Commands\CalcCplIssueUserLog;
use App\Console\Commands\CalcDayCurrency;
use App\Console\Commands\CalcDayStat;
use App\Console\Commands\CalcGoodsModifyStat;
use App\Console\Commands\CalcGuideStat;
use App\Console\Commands\CalcHourStat;
use App\Console\Commands\CalcKeysStat;
use App\Console\Commands\CalcMarketReportStat;
use App\Console\Commands\CalcOnlineStat;
use App\Console\Commands\CalcPayChannelStat;
use App\Console\Commands\CalcPayCntHourStat;
use App\Console\Commands\CalcSceneProfit;
use App\Console\Commands\CalcSceneRunningWater;
use App\Console\Commands\CalcStockProfit;
use App\Console\Commands\CalcTaskTypeStat;
use App\Console\Commands\CalcThirdTaskConfigStat;
use App\Console\Commands\CalcThirdTaskIssueStat;
use App\Console\Commands\CalcThirdTaskUserLog;
use App\Console\Commands\CalcUserExperience;
use App\Console\Commands\CheckBrokenMaster;
use App\Console\Commands\CheckRealNameStatus;
use App\Console\Commands\CheckThirdStatus;
use App\Console\Commands\CheckWithdrawOrder;
use App\Console\Commands\CleanExpired;
use App\Console\Commands\DelaySyncCpaCost;
use App\Console\Commands\ReportRealNameLoginOut;
use App\Console\Commands\SyncAlipayBill;
use App\Console\Commands\SyncBlackRemoteRepo;
use App\Console\Commands\SyncClientLogPlayerId;
use App\Console\Commands\SyncLuckyHbPlayer;
use App\Console\Commands\SyncPayOrderProfitSharing;
use App\Console\Commands\SyncRealNameStatus;
use App\Console\Commands\SyncSourceCpaCost;
use App\Console\Commands\SyncToMongo;
use App\Console\Commands\TaskNoticeMarquee;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    protected $commands = [

    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        if (!hasEnableCron()) return ;

        // horizon 指标
        $schedule->command('horizon:snapshot')->everyFiveMinutes();

        // 清除过期数据
        $schedule->command(CleanExpired::class)->dailyAt('3:00')->withoutOverlapping()->runInBackground();
        // 查询第三方服务状态
        $schedule->command(CheckThirdStatus::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 跑马条任务
        $schedule->command(TaskNoticeMarquee::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 统计各场次在线人数
        $schedule->command(CalcOnlineStat::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 计算库存利润
        $schedule->command(CalcStockProfit::class)->dailyAt('0:0')->withoutOverlapping()->runInBackground();
        // 同步渠道CPA花费
        $schedule->command(SyncSourceCpaCost::class)->everyTwoMinutes()->withoutOverlapping(10)->runInBackground();
        // 每日统计
        $schedule->command(CalcDayStat::class)->everyTwoMinutes()->withoutOverlapping()->runInBackground();
        // 检查权益订单
        $schedule->command(CheckWithdrawOrder::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 计算CPL任务完成情况
        $schedule->command(CalcCplIssueUserLog::class)->everyTwoMinutes()->withoutOverlapping()->runInBackground();
        // 统计CPL数据
        $schedule->command(CalcCplIssueStat::class)->hourlyAt(2)->withoutOverlapping()->runInBackground();
        // 用户日统计
        $schedule->command(CalcAccountDayStat::class)->everyFifteenMinutes()->withoutOverlapping()->runInBackground();
        // 检查实名状态
        // $schedule->command(CheckRealNameStatus::class)->everyFiveMinutes()->withoutOverlapping()->runInBackground();
        // 更新实名状态, 检查未成年是否已成年
        // $schedule->command(SyncRealNameStatus::class)->dailyAt('4:00')->withoutOverlapping()->runInBackground();
        // 上报实名认证用户登录登出数据
        // $schedule->command(ReportRealNameLoginOut::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 计算场次流水
        $schedule->command(CalcSceneRunningWater::class)->everyTwoMinutes()->withoutOverlapping()->runInBackground();
        // 计算ISSUE配置统计
        $schedule->command(CalcCplIssueConfigStat::class)->dailyAt('2:00')->withoutOverlapping()->runInBackground();
        // 计算玩家附属数据
        $schedule->command(CalcAccountExtraData::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 计算游戏活动数据
        $schedule->command(CalcActivityTypeInfo::class)->everyFiveMinutes()->withoutOverlapping()->runInBackground();
        // 计算游戏活动数据
        $schedule->command(CalcActivityTypeStat::class)->everyFiveMinutes()->withoutOverlapping()->runInBackground();
        // 计算场次盈利CPL支出 - 临时
        $schedule->command(CalcSceneProfit::class)->dailyAt('3:00')->withoutOverlapping()->runInBackground();
        // 计算时报
        $schedule->command(CalcHourStat::class)->hourlyAt(3)->withoutOverlapping()->runInBackground();
        // 计算新手引导统计数据
        $schedule->command(CalcGuideStat::class)->everyThreeMinutes()->withoutOverlapping()->runInBackground();
        // 计算物品变动统计
        $schedule->command(CalcGoodsModifyStat::class)->dailyAt('1:00')->withoutOverlapping()->runInBackground();
        // 通道统计
        $schedule->command(CalcPayChannelStat::class)->dailyAt('5:00')->withoutOverlapping()->runInBackground();
        // 订单分账
        $schedule->command(SyncPayOrderProfitSharing::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 计算支付次数时报
        $schedule->command(CalcPayCntHourStat::class)->everyTwoMinutes()->withoutOverlapping()->runInBackground();
        // 处理问题用户
        $schedule->command(CheckBrokenMaster::class)->hourly()->between('4:00', '6:00')->withoutOverlapping()->runInBackground();
        // 幸运红钻箱用户
        // $schedule->command(SyncLuckyHbPlayer::class)->hourlyAt(5)->withoutOverlapping()->runInBackground();
        // 延迟同步推广费
        $schedule->command(DelaySyncCpaCost::class)->dailyAt('1:30')->withoutOverlapping()->runInBackground();
        // 同步黑名单库
        $schedule->command(SyncBlackRemoteRepo::class)->hourlyAt(6)->withoutOverlapping()->runInBackground();
        // 同步支付宝资金账单
        $schedule->command(SyncAlipayBill::class)
            ->twiceDailyAt(9, 16, 30)
            ->withoutOverlapping()->runInBackground()
            ->appendOutputTo(storage_path('logs/alipayBillSync.log'));
        // 记录用户身上道具
        $schedule->command(CalcAccountDayProp::class)->dailyAt('01:30')->withoutOverlapping()->runInBackground();
        $schedule->command(CalcKeysStat::class)->dailyAt('03:30')->withoutOverlapping()->runInBackground();
        // mysql 同步 mongo
        $schedule->command(SyncToMongo::class)->dailyAt('04:10')->withoutOverlapping()->runInBackground();
        // 每日币值表计算
        $schedule->command(CalcDayCurrency::class)->hourlyAt(10)->withoutOverlapping()->runInBackground();
        // 同步clientLog表玩家ID
        $schedule->command(SyncClientLogPlayerId::class)->everyMinute()->withoutOverlapping()->runInBackground();
        // 计算市场上报统计
        $schedule->command(CalcMarketReportStat::class)->everyTwoMinutes()->withoutOverlapping()->runInBackground();
        // 统计玩家体感表
        $schedule->command(CalcUserExperience::class)->dailyAt("00:10")->withoutOverlapping()->runInBackground();
        // 三方任务统计
        $schedule->command(CalcThirdTaskUserLog::class)->everyMinute()->withoutOverlapping()->runInBackground();
        $schedule->command(CalcThirdTaskConfigStat::class)->hourlyAt(10)->withoutOverlapping()->runInBackground();
        $schedule->command(CalcThirdTaskIssueStat::class)->dailyAt("02:10")->withoutOverlapping()->runInBackground();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
